home *** CD-ROM | disk | FTP | other *** search
- program Tutorial1;
- {Point Rotation
- Made by fh94.3 (C) 12/23/1995
- Mail: fh@viktoria.drp.fmph.uniba.sk
-
- Based on explanation by Synergist (rtr0982@grace.rit.edu)
- }
- uses tutunit,crt;
-
- var x,y,z,xt,yt,zt:real; {virtual points, temp points}
- xan,yan,zan:real; {angles for X,Y,Z axis}
- sx,sy: integer; {screen coords}
-
- begin
- Mcgaon; {sets to 13h (320x200x256) mode}
- Zan := 0.3; {angle for rotation about Z axis}
- Yan := 0.1; {angle for rotation about Y axis}
- Xan := 0.1; {angle for rotation about X axis}
-
- x:=10; {coord of point on X axis}
- y:=20; {coord of point on Y axis}
- z:=20; {coord of point on Z axis}
-
- repeat
- SETPIXEL(SX,SY,0);
- Yt:= Y * COS(Xan) - Z * SIN(Xan); {calculates position after rotating}
- Zt:= Y * SIN(Xan) + Z * COS(Xan); {about the X axis}
- Y:= Yt;
- Z:= Zt;
- Xt:= X * COS(Yan) - Z * SIN(Xan); { ' ' about Y axis}
- Zt:= X * SIN(Yan) + Z * COS(Xan);
- X:= Xt;
- Z:= Zt;
- Xt:= X * COS(Zan) - Y * SIN(Zan); { ' ' about Z axis}
- Yt:= X * SIN(Zan) + Y * COS(Zan);
- X:= Xt;
- Y:= Yt;
- sx:=round(x)+160; {converts REAL to INTEGER,}
- sy:=round(y)+100; {160,100 is the centre of the screen}
-
- SETPIXEL(SX,SY,15); {draws the point}
- delay(30); {just a delay}
-
- until keypressed; {loops until you press a key}
-
- MCGAOff; {Back to text (old) mode}
- end.
-